package com.laowang.project.system.service.impl;

import java.util.List;

import com.laowang.common.exception.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.laowang.project.system.mapper.MyCyhClubAuthRelationMapper;
import com.laowang.project.system.domain.MyCyhClubAuthRelation;
import com.laowang.project.system.service.MyCyhClubAuthRelationService;

/**
 * 俱乐部认证条目关联Service业务层处理
 *
 * @author laowang
 * @date 2024-07-31
 */
@Service
public class MyCyhClubAuthRelationServiceImpl implements MyCyhClubAuthRelationService {
    @Autowired
    private MyCyhClubAuthRelationMapper myCyhClubAuthRelationMapper;

    /**
     * 查询俱乐部认证条目关联
     *
     * @param id 俱乐部认证条目关联ID
     * @return 俱乐部认证条目关联
     */
    @Override
    public MyCyhClubAuthRelation selectMyCyhClubAuthRelationById(Integer id) {
        return myCyhClubAuthRelationMapper.selectMyCyhClubAuthRelationById(id);
    }

    /**
     * 查询俱乐部认证条目关联列表
     *
     * @param myCyhClubAuthRelation 俱乐部认证条目关联
     * @return 俱乐部认证条目关联
     */
    @Override
    public List<MyCyhClubAuthRelation> selectMyCyhClubAuthRelationList(MyCyhClubAuthRelation myCyhClubAuthRelation) {
        return myCyhClubAuthRelationMapper.selectMyCyhClubAuthRelationList(myCyhClubAuthRelation);
    }

    /**
     * 新增俱乐部认证条目关联
     *
     * @param myCyhClubAuthRelation 俱乐部认证条目关联
     * @return 结果
     */
    @Override
    public int insertMyCyhClubAuthRelation(MyCyhClubAuthRelation myCyhClubAuthRelation) {
        Integer clubId = myCyhClubAuthRelation.getClubId();
        Integer optionId = myCyhClubAuthRelation.getOptionId();
        MyCyhClubAuthRelation myCyhClubAuthRelation1= myCyhClubAuthRelationMapper.selectOne(clubId,optionId);
        if (myCyhClubAuthRelation1 !=null){
            throw new CustomException("该关联已存在");
        }
        return myCyhClubAuthRelationMapper.insertMyCyhClubAuthRelation(myCyhClubAuthRelation);
    }

    /**
     * 修改俱乐部认证条目关联
     *
     * @param myCyhClubAuthRelation 俱乐部认证条目关联
     * @return 结果
     */
    @Override
    public int updateMyCyhClubAuthRelation(MyCyhClubAuthRelation myCyhClubAuthRelation) {
        Integer clubId = myCyhClubAuthRelation.getClubId();
        Integer optionId = myCyhClubAuthRelation.getOptionId();
        MyCyhClubAuthRelation myCyhClubAuthRelation1= myCyhClubAuthRelationMapper.selectOne(clubId,optionId);
        if (myCyhClubAuthRelation1!=null){
            if (!myCyhClubAuthRelation1.getId().equals(myCyhClubAuthRelation.getId())){
                throw new CustomException("要关联信息已存在");
            }
        }

        return myCyhClubAuthRelationMapper.updateMyCyhClubAuthRelation(myCyhClubAuthRelation);
    }

    /**
     * 批量删除俱乐部认证条目关联
     *
     * @param ids 需要删除的俱乐部认证条目关联ID
     * @return 结果
     */
    @Override
    public int deleteMyCyhClubAuthRelationByIds(Integer[] ids) {
        return myCyhClubAuthRelationMapper.deleteMyCyhClubAuthRelationByIds(ids);
    }

    /**
     * 删除俱乐部认证条目关联信息
     *
     * @param id 俱乐部认证条目关联ID
     * @return 结果
     */
    @Override
    public int deleteMyCyhClubAuthRelationById(Integer id) {
        return myCyhClubAuthRelationMapper.deleteMyCyhClubAuthRelationById(id);
    }
}
